{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">账号管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('staff.index/add')}"
                   data-auth-edit="{:$auth->check('staff.index/edit')}"
                   data-auth-delete="{:$auth->check('staff.index/del')}"></table>
        </div>
        <input type="hidden" id="adminId" value="{$adminId}">
    </div>

    <script type="text/html" id="barTool">
        <a data-open='{:url("edit")}?id={{ d.id }}'
           class="layui-btn layui-btn-xs {:$auth->check('staff.index/edit')?'':'layui-hide'}" title="编辑"><i
                class='iconfont icon-brush_fill'></i></a>
        <a href='{:url("del")}?id={{ d.id }}'
           class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('staff.index/del')?'':'layui-hide'}"><i
                class='iconfont icon-trash_fill'></i></a>
    </script>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
            modify_url: '{:url("multi")}',

        };


        var cloumns = [
            {field: 'id', width: 80, title: 'ID'},
            {field: 'username', title: '真实姓名', search: false},
            {field: 'phone', title: '手机号', searchOp: 'like'},

            {
                field: 'status',
                align: 'center',
                width: 120,
                title: '状态',
                unresize: true,
                templet: yznTable.formatter.switch,
                tips: "正常|冻结",
                selectList: {1: '正常', 0: '冻结'}
            },
            {field: 'create_time', title: '创建时间', search: false},
            {fixed: 'right', align: 'center', width: 140, title: '操作', toolbar: '#barTool'}
        ]

        var adminId = $('#adminId').val();
        if (adminId == 1) {
            cloumns.splice(2, 0, {field: 'admin.username', title: '团队', searchOp: 'like'});
        }

        table.render({
            init: init,
            toolbar: ['refresh', 'add'],
            url: '{:url("index")}',
            cols: yznTable.formatCols([cloumns], init),



            page: {}
        });
        yznTable.listenSwitch({filter: 'status', url: init.modify_url});
        yznTable.listenSwitch({filter: 'identity', url: init.modify_url});

        yznTable.bindevent();
    });
</script>
{/block}